package com.ssy.lingxi.search.repository;

import com.ssy.lingxi.search.entity.Commodity;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 商品ES搜索引擎层
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/7/28
 */
@Repository
public interface CommodityRepository extends ElasticsearchRepository<Commodity,Long>{

    List<Commodity> findByMemberIdAndCommodityShopListShopId(Long memberId, Long shopId);

    List<Commodity> findByCustomerCategoryCategoryIdAndCommodityShopListShopId(Long categoryId, Long shopId);

    List<Commodity> findByMemberIdAndCustomerCategoryIdAndCommodityShopListShopId(Long memberId, Long categoryId, Long shopId);

    List<Commodity> findByStoreIdAndCustomerCategoryIdAndCommodityShopListShopId(Long storeId, Long categoryId, Long shopId);

    List<Commodity> findByStoreIdAndCommodityShopListShopId(Long storeId, Long shopId);

    Commodity findByUnitPricePicListId(Long unitPricePicId);

    List<Commodity> findByUnitPricePicListIdIn(List<Long> unitPricePicId);

    Commodity findByMemberListUnitPricePicListId(Long unitPricePicId);

    List<Commodity> findByMemberListUnitPricePicListIdIn(List<Long> unitPricePicId);

    List<Commodity>  findByIdIn(List<Long> idList);

    List<Commodity> findByStoreIdAndPriceType(Long storeId, Integer priceType, Pageable page);

    List<Commodity> findByStoreIdAndPriceTypeIsNot(Long storeId, Integer priceType, Pageable page);

    List<Commodity> findByMemberListChannelMemberIdAndPriceType(Long channelMemberId, Integer priceType, Pageable page);

    List<Commodity> findByMemberListChannelMemberIdAndPriceTypeIsNot(Long channelMemberId, Integer priceType, Pageable page);

    List<Commodity> findByMemberListChannelMemberIdAndMemberListChannelMemberRoleId(Long channelMemberId, Long channelMemberRoleId);

    List<Commodity> findByMemberIdAndMemberRoleId(Long memberId, Long memberRoleId);

    List<Commodity> findByBrandId(Long brandId);

    List<Commodity> findByStoreIdInAndCommodityShopListShopIdOrderByPublishTimeDesc(List<Long> storeIdList, Long shopId);

    List<Commodity> findByBrandIdInAndCommodityShopListShopId(List<Long> brandIdList, Long shopId);

    List<Commodity> findByMemberListIdIn(List<Long> channelCommodityMemberIdList);

    List<Commodity> findByCustomerCategoryCategoryFullIdStartingWithAndCommodityShopListShopId(String customerCategoryId, Long shopId);

    List<Commodity> findByCommodityShopListShopId(Long shopId);

//    Commodity findFirstByMemberListChannelCommodityId(Long channelCommodityId);

    Commodity findFirstByMemberListChannelCommodityMemberId(Long channelCommodityMemberId);

    List<Commodity> findByMemberListChannelCommodityId(Long channelCommodityId);

    List<Commodity> findByCustomerCategoryFullIdStartingWithAndCommodityShopListShopId(String format, Long shopId);

    List<Commodity> findByCustomerCategoryFullIdStartingWithAndMemberListShopListShopId(String format, Long shopId);
}
